package controllers

import (
	"github.com/gin-gonic/gin"
	"my-gin-tiktok/app/daos"
	"my-gin-tiktok/app/services"
	"my-gin-tiktok/common/response"
	"strconv"
)

// FavoriteVideo 点赞视频
func FavoriteVideo(ctx *gin.Context) {
	var form daos.FavVideo
	if err := ctx.ShouldBind(&form); err != nil {
		response.ValidateFail(ctx, err.Error())
		return
	}

	userID, _ := strconv.ParseInt(ctx.Keys["id"].(string), 10, 64)
	err := services.FavoriteService.CreateFavorite(ctx, userID, form.VideoId)
	if err != nil {
		response.BusinessFail(ctx, err.Error())
		return
	}
	response.Success(ctx, nil)
}

// FavoriteVideoList 点赞视频列表
func FavoriteVideoList(ctx *gin.Context) {
	userID, _ := strconv.ParseInt(ctx.Keys["id"].(string), 10, 64)
	videoList, err := services.FavoriteService.GetFavoriteVideoList(ctx, userID)
	if err != nil {
		response.BusinessFail(ctx, err.Error())
		return
	}
	response.Success(ctx, videoList)
}

// FavoriteComment 点赞评论
func FavoriteComment(ctx *gin.Context) {
	var form daos.FavComment
	if err := ctx.ShouldBind(&form); err != nil {
		response.ValidateFail(ctx, err.Error())
		return
	}
	response.Success(ctx, nil)
}

// FavoriteCommentList 点赞评论列表
func FavoriteCommentList(ctx *gin.Context) {
	response.Success(ctx, nil)
}
